import request from '@/utils/request'

// 登录方法
export function login(username, password, code, uuid) {
	const data = {
		username,
		password,
		code,
		uuid
	}
	return request({
		'url': '/app/auth/login',
		headers: {
			isToken: false
		},
		'method': 'post',
		'data': data
	})
}

// 注册方法
export function register(data) {
	return request({
		url: '/register',
		headers: {
			isToken: false
		},
		method: 'post',
		data: data
	})
}

// 获取用户详细信息
export function getInfo() {
	return request({
		'url': '/getInfo',
		'method': 'get'
	})
}

// 退出方法
export function logout() {
	return request({
		'url': '/logout',
		'method': 'post'
	})
}


// 获取验证码
export function getCodeImg() {
	return request({
		'url': '/captchaImage',
		headers: {
			isToken: false
		},
		method: 'get',
		timeout: 20000
	})
}



// 注册-获取验证码
export function registerPhoneCode(phoneNumber) {
	return request({
		url: '/app/auth/register/phone/code',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			'phoneNumber': phoneNumber,
			'phoneCode': 'string'
		}
	})
}

// 注册-验证码验证
export function registerPhoneCodeVerify(phoneNumber,phoneCode) {
	return request({
		url: '/app/auth/register/phone/code/verify',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			'phoneNumber': phoneNumber,
			'phoneCode': phoneCode
		}
	})
}

// 注册
export function registerPhone(phoneNumber,password) {
	return request({
		url: '/app/auth/registerByPhone',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			'phoneNumber': phoneNumber,
			'password': password
		}
	})
}

// 账号密码登录
export function loginUsername(username,password) {
	return request({
		url: '/app/auth/login',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			'mobile': username,
			'password': password
		}
	})
}

// 手机验证码登录-获取验证码
export function loginPhoneCode(phoneNumber) {
	return request({
		url: '/app/auth/login/phone/code',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			'phoneNumber': phoneNumber,
			'phoneCode': 'string'
		}
	})
}

// 手机验证码登录
export function loginPhone(phoneNumber,phoneCode) {
	return request({
		url: '/app/auth/phoneLogin',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			'phoneNumber': phoneNumber,
			'phoneCode': phoneCode
		}
	})
}

// 更新密码验证码
export function updatePasswordCode(phoneNumber) {
	return request({
		url: '/app/auth/phone/updatePwd/code',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			'phoneNumber': phoneNumber,
			'phoneCode': 'string'
		}
	})
}

// 更新密码
export function updatePassword(phoneNumber,phoneCode,passwd) {
	return request({
		url: '/app/auth/phone/updatePwd',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			'phoneNumber': phoneNumber,
			'phoneCode': phoneCode,
			'passwd': passwd
		}
	})
}